package com.ejianlong.tongchuang.myhiltdemo.bean

import javax.inject.Inject

/**
 * truck 所有的构造函数总所依赖的对象 都支持依赖注入之后,truck 才支持依赖注入
 * 如果Driver中也包含参数,也是同样的道理
 */
class Truck @Inject constructor(private val driver: Driver){

    @BindGasEngine
    @Inject
    lateinit var gasEngine: Engine

    @BindElectricEngine
    @Inject
    lateinit var electricEngine: Engine

    @BindNormalHorn
    @Inject
    lateinit var normalHorn: Horn

    @BindGoodHorn
    @Inject
    lateinit var goodHorn: Horn



    fun deliver(){
        gasEngine.start()
        println("Truck is delivering cargo,driven by $driver")
        gasEngine.shutDown()



        electricEngine.start()
        electricEngine.shutDown()
    }

    fun hornSounded(){
        normalHorn.sounded()
        goodHorn.sounded()
    }

}